<template>
  <div>
    <button @click="downloadExcel">下载excel</button>
  </div>
</template>

<script>
import axios from 'axios'

const instance = axios.create()

export default {
  data () {
    return {

    }
  },
  methods: {
    async downloadExcel () {
      const res = await instance.post('/q/exportExcel', {
        responseType: 'arraybuffer'
      })
      // window.open(data)
      const blob = new Blob([res.data], {
        type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
      })
      const objectUrl = URL.createObjectURL(blob)
      const link = document.createElement('a')
      link.setAttribute('href', objectUrl)
      link.setAttribute('download', '国际化.xlsx')
      document.body.appendChild(link)
      link.click()
      document.body.removeChild(link)
    }
  }
}
</script>

<style>

</style>